<template>
	<view>
		<zmm-watermark :watermark="userStore.watermark" v-if="userStore.watermark"></zmm-watermark>
		<view class="content detail">
			<!--提成明细-->
			<view class="detail-item">
				<uni-section title="提成明细" type="line"></uni-section>
				<view class="detail-content table">
					<ty-table
						:data="tableList"
						:columns="columns"
						:sortable="true"
						:cellClassName="() => 'table-cell'"
						:headerCellClassName="() => 'table-cell'"
						:rowClassName="() => 'table-row'"
						stripe
						border>
						<template v-slot:before="{ row }">
							<view class="table-td-before table-cell table-td-row">
								<view class="table-td-row">
									订单编号：
									<text class="table-td-text">{{row.orderNumber}}</text>
									<text class="detail-text-copy" @click="copyText(row.orderNumber)">复制</text>
								</view>
								<view class="table-td-row main-flex">
									<view class="table-td-row main-flex-item">
										下单时间：
										<text class="table-td-text">{{row.createTime}}</text>
									</view>
									<view class="table-td-row main-flex-item">
										完成时间：
										<text class="table-td-text">{{row.completeTime}}</text>
									</view>
								</view>
								<view class="table-td-row">
									订单备注：
									<text class="table-td-text">{{row.remark}}</text>
								</view>
							</view>
						</template>
						<template v-slot:left="{ row }">
							<view class="table-td-cell">
								<view class="table-td-row">
									配送仓库：
									<text class="table-td-text">{{row.warehouseName}}</text>
								</view>
								<view class="table-td-row">
									客户姓名：
									<text class="table-td-text">{{row.customerName}}</text>
								</view>
								<view class="table-td-row">
									客户店铺：
									<text class="table-td-text">{{row.company}}</text>
								</view>
							</view>
						</template>
						<template v-slot:right="{ row }">
							<view class="table-td-cell">
								<view class="table-td-row">
									应付金额：
									<text class="table-td-text">{{row.originalPrice}}</text>
								</view>
								<view class="table-td-row">
									实付金额：
									<text class="table-td-text">{{row.actualPrice}}</text>
								</view>
								<view class="table-td-row">
									提成：
									<text class="table-td-text"></text>
								</view>
							</view>
						</template>
					</ty-table>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { computed, onMounted, ref } from 'vue';
import { tab, auth, modal } from "@/plugins"
import { getTitle } from "@/utils/getter"
import { checkPermi, checkRole, checkOnlyPermi, checkOnlyRole } from "@/utils/permission"
import { warehouseCheckingDetail } from "@/api/erp_api/finance"
import { productDetail } from "@/api/erp_api/product"
import { copyText, arrText } from '@/utils/ty.js';
import useUserStore from '@/store/modules/user'

	const userStore = useUserStore()	
	onLoad((option) => {
		if (option.warehouseId) {
			warehouseId.value = option.warehouseId
			checkingMonth.value = option?.checkingMonth || ''
			getProductDetail()
		}
	})
	
	// 数据查询
	const warehouseId = ref('')
	const checkingMonth = ref('')
	const tableList = ref([])
	const isLoading = ref(false)
	
	// 表格头部
	const columns = ref([
		{ title: '订单信息', key: 'left' },
		{ title: '数量金额', key: 'right' }
	])
	
	const getProductDetail = () => {
		const params = {
			warehouseId: warehouseId.value,
			checkingMonth: checkingMonth.value
		}
		isLoading.value = true
		uni.showLoading({
			title: '数据加载中...'
		})
		warehouseCheckingDetail(params).then(res => {
			tableList.value = res.data || []
			isLoading.value = false
			uni.hideLoading()
    }).catch(() => {
			isLoading.value = false
			uni.hideLoading()
		})
	}
	
</script>

<style scoped>
</style>
